package org.dioib.practice.mapper;

import org.apache.ibatis.annotations.*;
import org.dioib.practice.model.SysUser;

import java.util.List;
import java.util.Map;

@Mapper //配置类加了扫描注解@MapperScan此处可省略
public interface DiscardSysUserMapper {

    @Select("select * from sys_user")
    public List<SysUser> findAll();

    @Insert("insert into sys_user(first_name,last_name,password,email,address,sex,age,phone) " +
            "values(#{firstName},#{lastName},#{password},#{email},#{address},#{sex},#{age},#{phone});")
    int insert(SysUser user);

    @Delete("delete from sys_user where id=#{id}")
    //@Update("update sys_user set status=1 where id=#{id}")
    int delete(SysUser sysUser);
    //int delete(@Param("id") SysUser sysUser); //加上注解等同于 sysUser = id；所以会出错

    @Update("update sys_user set first_name=#{firstName},last_name=#{lastName},password=#{password},email=#{email},address=#{address},sex=#{sex},age=#{age},phone=#{phone}" +
            " where id = #{id})")
    int update(SysUser sysUser);

    @Select("select * from sys_user where first_name = #{firstName}")
    List<SysUser> findOne(String firstName);

    @Select("select count(*) from sys_user where status = 0 and id = #{id}")
    Integer selectTotal(Integer id);

//    List<SysUser> listAll();

//    List<SysUser> selectSysUser(SysUser sysUser);


    int updateSysUser(SysUser sysUser);
    int totalSelect(Map<String, Object> map);
    List<SysUser> findByPage(Map<String, Object> map);

//    int deleteSysUser(SysUser sysUser);
//
//    int insertSysUser(SysUser sysUser);
}
